<?php
	require_once $ubi['SERVER']['SERVER_ROOT'] . '/utility/generalFunctions.php';
	
	require_once $ubi['SERVER']['SERVER_ROOT'] . '/dao/daoResource.php';
	
	class ResourceBus {
		private $_resourceDao;	
	
		public function __construct() {
			$this->_resourceDao = new ResourceDao();
		}
		
		public function addResource($resource) {
			$resource->setResourceName(GeneralFunctions::stripString($resource->getResourceName()));
			
			$currentTime = $_SERVER['REQUEST_TIME'];
			$resource->setCreatedDate($currentTime);
			
			return $this->_resourceDao->addResource($resource);
		}
				
		public function deleteResource($resID) {
			$this->_resourceDao->deleteResource($resID);
		}
		
		public function getResource($resID) {
			return $this->_resourceDao->getResource($resID);
		}
		
		public function getImgOfResource($resID) {
			$res = $this->_resourceDao->getResource($resID);
			if (isset($res)) {
				GeneralFunctions::resizeImageResource($res->getResourceName());	
				return $res->getResourceName();
			}
		}
	} 
?>